package com.bytedance.scenedemo;

import com.bytedance.scene.group.UserVisibleHintGroupScene;
import com.bytedance.scene.navigation.NavigationSceneGetter;
import com.bytedance.scenedemo.animatiom.AnimationResDemoScene;
import com.bytedance.scenedemo.animatiom.SlideBackButtonDemoScene;
import com.bytedance.scenedemo.animatiom.SwipeBackDemo;
import com.bytedance.scenedemo.animatiom.TransitionDemo;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Button;
import ohos.agp.components.Component;
import ohos.agp.components.ComponentContainer;
import ohos.agp.components.LayoutScatter;

/**
 * Created by JiangQi on 8/9/18.
 */
public class AnimationListDemoScene extends UserVisibleHintGroupScene implements Component.ClickedListener {
    public  Button btnIosInteractionAnimation;

    @Override
    public ComponentContainer onCreateView(LayoutScatter inflater, ComponentContainer container, Intent savedInstanceState) {
        ComponentContainer componentContainer = (ComponentContainer) inflater.parse(ResourceTable.Layout_animation_list_demo_scene, container, false);
        initView(componentContainer);
        return componentContainer;
    }

    private void initView(ComponentContainer componentContainer) {
        Button btnXmlAnimatedTransitions = (Button) componentContainer.findComponentById(ResourceTable.Id_btn_xml_animated_transitions);
        Button btnSlideBackAnimation = (Button) componentContainer.findComponentById(ResourceTable.Id_btn_slide_back_animation);
        btnIosInteractionAnimation = (Button) componentContainer.findComponentById(ResourceTable.Id_btn_ios_interaction_animation);
        Button btnSharedElementAnimation = (Button) componentContainer.findComponentById(ResourceTable.Id_btn_shared_element_animation);
        btnXmlAnimatedTransitions.setClickedListener(this);
        btnSlideBackAnimation.setClickedListener(this);
        btnIosInteractionAnimation.setClickedListener(this);
        btnSharedElementAnimation.setClickedListener(this);
    }

    @Override
    public void onClick(Component component) {
        int id = component.getId();
        switch (id) {
            case ResourceTable.Id_btn_xml_animated_transitions:
                NavigationSceneGetter.requireNavigationScene(this).push(AnimationResDemoScene.class);
                break;
            case ResourceTable.Id_btn_slide_back_animation:
                NavigationSceneGetter.requireNavigationScene(this).push(SwipeBackDemo.class);
                break;
            case ResourceTable.Id_btn_ios_interaction_animation:
                NavigationSceneGetter.requireNavigationScene(this).push(SlideBackButtonDemoScene.class);
                break;
            case ResourceTable.Id_btn_shared_element_animation:
                NavigationSceneGetter.requireNavigationScene(this).push(TransitionDemo.class);
                break;
            default:
                break;
        }
    }

}